<?php
$p_crud_on = false;
$p_jobadmin_on = false;
$p_jobadminall_on = false;
$p_jobadminassigned_on = false;

$p_jobadmin_value = 0;

if ($_["user"]->permissions & PERMISSION_JOB_CRUD) {
   $p_crud_on = true;
}

if ($_["user"]->permissions & PERMISSION_JOB_ADMIN_ALL) {
   $p_jobadminall_on = true;
   $p_jobadmin_value = PERMISSION_JOB_ADMIN_ALL;
} elseif ($_["user"]->permissions & PERMISSION_JOB_ADMIN_ASSIGNED) {
   $p_jobadminassigned_on = true;
   $p_jobadmin_value = PERMISSION_JOB_ADMIN_ASSIGNED;
}

$p_jobadmin_on = $p_jobadminall_on || $p_jobadminassigned_on;

$uid = JRequest::getString('uid', '');

?>
<form id="edituser" name="edituser" class="saveuser" method="post" action="<?=OC_Helper::linkTo('company','ajax/updatesubaccount.php')?>" autocomplete="off">
   <div class="control-group">
    <label class="control-label key" for=""><em class="redstar">*</em> 姓<em class="nbspem"></em>名：</label>
    <div class="controls">
      <input type="text" name="displayname" placeholder="" value="<?=$_["user"]->displayname?>">
    </div>
   </div>
   <div class="control-group">
    <label class="control-label" for=""><em class="redstar">*</em> 登录邮箱：</label>
    <div class="controls">
      <input type="hidden" name="username" value="<?=$_["user"]->uid?>">
      <span><?=$_["user"]->uid?></span>
    </div>
   </div>
   <div class="control-group">
    <label class="control-label" for=""><em class="redstar">*</em> 密<em class="nbspem"></em>码：</label>
    <div class="controls">
      <span><a href="javascript:;" id="changepsswordtext">修改密码</a></span>
    </div>
   </div>
   <div class="control-group" id="changepsswordinput" style="display:none;">
    <div class="controls">
      <input type="password" name="password" placeholder="密码长度6～15位，字母区分大小写">
    </div>
   </div>
   <div class="control-group">
    <label class="control-label" for="">备<em class="nbspem"></em>注：</label>
    <div class="controls">
      <input type="text" name="note" placeholder="32个字符以内，如：本公司招聘负责人" style="width:320px;" value="<?=$_["user"]->note?>">
    </div>
   </div>
   <div class="control-group">
    <label class="control-label" for=""><em class="redstar">*</em> 权<em class="nbspem"></em>限：</label>
    <div class="controls">
      <div class="purview_each">
         <label class="checkbox">
            <input type="checkbox" checked disabled> <b>查看职位和简历</b>
         </label>
      </div>
      <div class="purview_each">
         <label class="checkbox purviewcheckbox_first" style="position:relative;">
            <input type="checkbox" name="permission[]" value="<?=PERMISSION_JOB_CRUD?>" <?=($p_crud_on ? "checked" : "")?>> <b>发布职位</b> <em class="graycolor">(可创建新职位，并可管理创建的职位)</em>
         </label>
      </div>
      <div class="purview_each" style="border-bottom:0px; margin-bottom:0px;">
         <label class="checkbox purviewcheckbox_second">
            <input type="checkbox" name="permission[]" value="<?=$p_jobadmin_value?>" class="jobmanage" <?=($p_jobadmin_on ? "checked" : "")?>> <b>管理职位</b> <em class="graycolor">(可管理全部或指定职位，包括职位同步、关闭、修改、招聘设置及简历)</em>
         </label>
      </div>
      <div class="purview_eachlast medium <?=($p_jobadmin_on ? "" : "graycolor")?>">
         <label class="radio inline">
            <input type="radio" <?=($p_jobadmin_on ? "" : "disabled")?> name="radio1" value="<?=PERMISSION_JOB_ADMIN_ALL?>" class="alljobs" <?=($p_jobadminall_on ? "checked" : "")?>> 全部职位 <em style="color:#ff6600;" class="yellow" <?=($p_jobadmin_on ? '' : 'style="display:none;"')?>>(包括以后创建的职位)</em>
         </label>
         <label class="radio inline">
            <input type="radio" <?=($p_jobadmin_on ? "" : "disabled")?> name="radio1" value="<?=PERMISSION_JOB_ADMIN_ASSIGNED?>" class="partjobs" <?=($p_jobadminassigned_on ? "checked" : "")?>> 指定职位 <em style="color:#ff6600;" class="yellow" <?=($p_jobadmin_on ? '' : 'style="display:none;"')?>>(包括该子账号创建的职位)</em><a data-uid="<?=$uid?>" href="javascript:;" class="clicktochange assignjobs showlist" <?=($p_jobadminassigned_on ? '' : 'style="display:none;"')?>>修改</a>
         </label>
      </div>
      <div class="purposlistbox" <?=(($p_jobadminassigned_on && !empty($_['assignedJobs'])) ? '' : 'style="display:none;"')?>>
         <i style="left:260px;"></i>
         <table width="100%" border="0" cellpadding="0" cellspacing="0" class="jobtable">
            <?php if (!empty($_['assignedJobs'])): ?>
            <tr>
               <?php 
               $n=count($_['assignedJobs']);
               for ($i=0; $i < $n; $i++) {
                  $job = $_['assignedJobs'][$i];
                  if ($i != 0 && ($i%3) == 0) {
                     echo '</tr><tr>';
                  }
                  $jobData = "{'jobtitle': '" . $job['job_title'] . "', 'jobid': '" . $job['id'] . "'}";
               ?>
               <td width="33%"><?=$job['job_title']?><input type="hidden" name="assignedjobs[]" value="<?=$job['id']?>"></td>
               <?php 
               }
               
               $filledNum = 3 - ($n%3);
               if ($filledNum < 3) {
                  for ($i=0; $i < $filledNum; $i++) {
                     echo '<td width="33%"></td>';
                  }
               }
               ?>
            </tr>
            <?php endif; ?>
         </table>
      </div>
    </div>
   </div>
   <div class="control-group">
    <div class="controls">
      <span class="lastactionbtn"><a href="javascript:;" class="ppp_bluebtn sure">确认</a></span>
      <span class="lastactionbtn"><a href="javascript:;" class="ppp_whitebtn cancel">取消</a></span>
      <span class='error server'></span>
      <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
    </div>
   </div>
</form>
